package cn.phecda.boot.job.xxljob.handler;

import com.xxl.job.core.context.XxlJobHelper;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Optional;

/**
 * <p>基础的任务处理</p>
 *
 * @author wanpinwei
 */
public class BaseJobHandler {
    protected Optional<String> getParam() {
        String url = XxlJobHelper.getJobParam();
        if (ObjectUtils.isEmpty(url)) {
            XxlJobHelper.log("param["+ url +"] invalid.");

            XxlJobHelper.handleFail();
            return Optional.empty();
        }

        return Optional.of(url);
    }

}
